import java.util.Map;

import cn.tbox.sdk.TboxClient;
import cn.tbox.sdk.core.exception.TboxClientConfigException;
import cn.tbox.sdk.core.exception.TboxHttpResponseException;
import cn.tbox.sdk.core.http.HttpClientConfig;
import cn.tbox.sdk.model.request.ChatRequest;

public class Demo {
    private static final String YOUR_TOKEN = "TBox-23b16e8eb89c477b9daf5c8b181a856e";
    private static final String YOUR_APP_ID = "202511APY9A100562855";

    public static void main(String[] args) throws TboxClientConfigException, TboxHttpResponseException {
        // 初始化客户端
        TboxClient client = new TboxClient(new HttpClientConfig(YOUR_TOKEN));

        String appId = YOUR_APP_ID;
        String query = "你是谁";
        String userId = "1001";

        ChatRequest chatRequest = new ChatRequest(appId, query, userId);

        @SuppressWarnings("unchecked")
        Iterable<Map<String, Object>> response = (Iterable<Map<String, Object>>) client.chat(chatRequest);
        for (Map<String, Object> chunk : response) {
            System.out.println(chunk); // 输出流式响应
        }

    }

}